<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="#{webContext.skin0Culomns}"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="center">
        <h:form id="listForm">
            <p:breadCrumb>  
                <p:menuitem value="#{ml.tr('Home')}" url="#{webContext.baseUrl}" />  
                <p:menuitem value="#{ml.tr('Action list')}" url="#" />  
            </p:breadCrumb>
            <p:toolbar>
                <p:toolbarGroup align="left">

                    <p:commandButton type="submit"
                                     value="#{ml.tr('Add')}"
                                     image="ui-icon-plus"
                                     actionListener="#{man.redirect(lm.ml('action/add.xhtml'))}"/>

                    <p:commandButton type="submit"
                                     value="#{ml.tr('Show')}"
                                     image="ui-icon-search"
                                     actionListener="#{actionShow.show(actionList.selectedAction)}"/>

                    <p:commandButton type="submit"
                                     value="#{ml.tr('Edit')}"
                                     image="ui-icon-pencil"
                                     actionListener="#{actionAdd.redirectToEdit(actionList.selectedAction)}"/>
                    
                    <p:commandButton type="submit"
                                     value="#{ml.tr('Copy')}"
                                     image="ui-icon-plus"
                                     actionListener="#{actionAdd.redirectToCopy(actionList.selectedAction)}"/>

                    <p:commandButton type="button"
                                     onclick="confirmationDelete.show()"
                                     update="display"
                                     image="ui-icon ui-icon-circle-close"
                                     value="#{ml.tr('Delete')}"/>     
                    <p:confirmDialog message="#{ml.tr('Are you sure?')}"  
                                     header="#{ml.tr('Deleting action')}" 
                                     severity="alert" widgetVar="confirmationDelete">  
                        <p:commandButton value="#{ml.tr('Yes')}" 
                                         update="userList" 
                                         oncomplete="confirmationDelete.hide()"  
                                         action="#{actionList.remove()}"
                                         />  
                        <p:commandButton value="#{ml.tr('No')}" 
                                         onclick="confirmationDelete.hide()" 
                                         type="button" />
                    </p:confirmDialog>

                </p:toolbarGroup>
            </p:toolbar>

            <p:dataTable id="userList" var="action" value="#{actionList.allAction}"
                         paginator="true" rows="#{constants.DATATABLE_ROWS}"
                         selection="#{actionList.selectedAction}" selectionMode="single">

                <f:facet name="header">
                    "#{ml.tr('List of actions')}"
                </f:facet>

                <p:column sortBy="#{action.fromDate.time}" 
                          headerText="#{ml.tr('From')}">
                    <h:outputText value="#{action.fromDate.toLocaleString()}" />
                </p:column>
                
                <p:column headerText="#{ml.tr('To')}">
                    <h:outputText value="#{action.toDate.toLocaleString()}" />
                </p:column>
                
                <p:column filterBy="#{action.name}"
                          headerText="#{ml.tr('Name')}"
                          filterMatchMode="contains">
                    <h:outputText value="#{action.name}" />
                </p:column>
                
                
                
            </p:dataTable>

        </h:form>
    </ui:define>

</ui:composition>
